package com.banmajio.mapper;

import com.banmajio.bean.Kdp01;
import com.banmajio.entity.VolunteerInfo;
import com.banmajio.pojo.XtVolunteerInfo;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


@DS("master")
@Mapper
public interface XtVolunteerInfoMapper extends BaseMapper<XtVolunteerInfo> {

    Integer insertVolunteerInfo(@Param("obj") XtVolunteerInfo xtVolunteerInfo);

    Integer batchInsert(@Param("list") List<XtVolunteerInfo> list);

    Long getId();



    @Insert("<script>" +
            "INSERT INTO ${targetTable} " +
            "<trim prefix='(' suffix=')' suffixOverrides=','> " +
            "<foreach collection='fieldNames' item='field' separator=','> " +
            "${field} " +  // 动态生成字段列表
            "</foreach> " +
            "</trim> " +
            "VALUES " +
            "<foreach collection='dataList' item='item' separator=','> " +
            "<trim prefix='(' suffix=')' suffixOverrides=','> " +
            "<foreach collection='fieldValues' item='field' separator=','> " +
            "#{item.${field}} " +  // 动态生成值列表
            "</foreach> " +
            "</trim> " +
            "</foreach>" +
            "</script>")
    void batchInsertInfo(
            @Param("dataList")List<VolunteerInfo> dataList,
            @Param("targetTable") String targetTable,
            @Param("fieldNames") List<String> fieldNames,
            @Param("fieldValues") List<String> fieldValues
    );


    @Select("SELECT nextval(#{sequenceName}) + ${count} - 1")
    long getNextValue(@Param("sequenceName") String sequenceName, @Param("count") int count);
}
